﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GiftList.aspx.cs" Inherits="PersonInfo_GiftList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="<%= ResolveUrl("~/jquery-easyui-1.2.6/themes/"+Skin+"/easyui.css") %>"
        rel="stylesheet" type="text/css" />
    <link href="../jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="../Content/js/sysEasyUI.js" type="text/javascript"></script>
    <script type="text/javascript">
        var selectRow;
        $(function () {
            getData(0, 10);
        });
        function getData(pn, pz) {
            $('#grid').datagrid({
                nowrap: false,
                striped: true,
                singleSelect: true,
                collapsible: true,
                url: 'GiftList.aspx?para=GetList&startIndex=' + pn,
                sortName: 'ID',
                sortOrder: 'asc',
                idField: 'ID',
                height: 'auto',
                pageList: [5, 10, 20],
                pageSize: 20,
                fitColumns: true,
                columns: [[

                            { field: 'SKU', title: '编号', width: 200, sortable: true },
                            { field: 'Name', title: '名称', width: 200, sortable: true },
                             { field: 'Price', title: '价格', width: 200 },
                            { field: 'Integral', title: '兑换积分', width: 200 },
                            { field: 'begin_inv', title: '仓库余量(非实时)', width: 200 },
                                            { field: 'REDP_INV', title: '兑换限量', width: 200 },
                                            { field: 'SALES_INV', title: '销售限量', width: 200 },
                                            { field: 'EXCH_NUM', title: '一次兑换上限', width: 200 }
                                            ,
                                            { field: 'mx', title: '是否明星', width: 200 },
                                            { field: 'tj', title: '是否推荐', width: 200 },
                                            { field: 'xp', title: '是否新品', width: 200 },
                                            { field: 'xl', title: '是否销量', width: 200 },
                                            { field: 'ZS', title: '是否展示', width: 200 },
                                            { field: 'DL', title: '是否兑礼', width: 200 }
        				]],
                pagination: true,
                rownumbers: true,
                onHeaderContextMenu: function (e, field) {
                    e.preventDefault();
                    if (!$('#tmenu').length) {
                        createColumnMenu("grid");
                    }
                    $('#tmenu').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    });
                },
                onRowContextMenu: function (e, rowIndex, rowData) {
                    if ($.trim(rowData.ID) == "") {
                        var aa = $("#mm div");
                        for (var a = 0; a < aa.length; a++) {
                            var item = aa[a];
                            if (item.innerText == "修改" || item.innerText == "删除" || item.innerText == "下架") {
                                $(item).css({ display: "none" });
                                $(item).parent().css({ display: "none" });
                            }
                        }
                    }
                    selectRow = rowData;
                    e.preventDefault();
                    $(this).datagrid('unselectAll');
                    $(this).datagrid('getRows', rowData.code);
                    $('#mm').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    });
                }
            });
        }

        function Add() {
            openWindow("GiftEdit.aspx?para=add", 800, 450);
        }
        function AddK() {
            openWindow("InventoryEdit.aspx?para=add&id=" + selectRow.ID, 350, 400);
        }
        function ShowK() {
            openWindow("InventoryList.aspx?id=" + selectRow.ID, 800, 450);
        }
        function ShowD() {
            location = "GiftList.aspx?para=excel&id=" + selectRow.ID;
        }
        function Update() {
            openWindow("GiftEdit.aspx?para=update&id=" + selectRow.ID, 800, 450);
        }

        function Show() {
            openWindow("IntegralChangeList.aspx?id=" + selectRow.ID, 1000, 450);
        }

        function Delete() {
            $.messager.confirm("提示", "确定要删除吗？", function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        async: false,
                        url: "GiftList.aspx?para=delete&id=" + selectRow.ID,
                        success: function (data) {
                            if (data == "ok") {
                                alert("删除成功");
                                $("#grid").datagrid("reload");
                            }
                            else {
                                alert(data);
                            }
                        }
                    });
                }
            });
        }

        function Delete2() {
            $.messager.confirm("提示", "确定要下架吗？", function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        async: false,
                        url: "GiftList.aspx?para=delete2&id=" + selectRow.ID,
                        success: function (data) {
                            if (data == "ok") {
                                alert("下架成功");
                                $("#grid").datagrid("reload");
                            }
                            else {
                                alert(data);
                            }
                        }
                    });
                }
            });
        }

        function btnSearch() {
            $('#grid').datagrid('load', {
                GiftNo: $("#txtGiftNo").val(),
                Name: $("#txtName").val(),
                JF: $("#txtJF").val(),
                K1: $("#txtK1").val(),
                K2: $("#txtK2").val()
            });
        }

        function btnSearch2() {
            $('#Button1').click();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td>
                    商品编号：
                </td>
                <td>
                    <asp:TextBox ID="txtGiftNo" runat="server"></asp:TextBox>
                </td>
                <td>
                    商品名称:
                </td>
                <td>
                    <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                </td>
                <td rowspan="2">
                    <a class="easyui-linkbutton" onclick="btnSearch()">查询</a> <a class="easyui-linkbutton"
                        onclick="btnSearch2()">导出Excel</a>
                    <asp:Button ID="Button1" runat="server" Style="display: none;" OnClick="Button1_Click"
                        Text="Button" />
                </td>
            </tr>
            <tr>
                <td>
                    兑换积分
                </td>
                <td>
                    <asp:TextBox ID="txtJF" runat="server"></asp:TextBox>
                </td>
                <td>
                    当前库存
                </td>
                <td>
                    <asp:TextBox ID="txtK1" runat="server" Width="65px"></asp:TextBox>
                    --<asp:TextBox ID="txtK2" runat="server" Width="65px"></asp:TextBox>
                </td>
            </tr>
        </table>
    </div>
    <div>
        <table id="grid">
        </table>
        <div id="mm" class="easyui-menu" style="width: 120px;">
            <%--<div onclick="Add()" iconcls="icon-add">
                添加商品</div>--%>
            <div onclick="Update()" iconcls="icon-save">
                修改商品</div>
            <%--  <div onclick="Delete()" iconcls="icon-cancel">
                删除商品</div>--%>
            <div onclick="Delete2()" iconcls="icon-cancel">
                商品下架</div>
            <%-- <div onclick="AddK()" iconcls="icon-add">
                添加库存</div>
                <div onclick="ShowK()" iconcls="icon-add">
                查看库存明细</div>
                <div onclick="ShowD()" iconcls="icon-add">
                导出库存明细</div>--%>
        </div>
    </div>
    </form>
</body>
</html>
